package com.evan.wj.dao;

import com.evan.wj.pojo.Bookshelf;
import com.evan.wj.pojo.ViewBS;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface BookshelfDao extends JpaRepository<Bookshelf,Integer> {

    @Query(nativeQuery = true, value = "select u.id as uid,b.id as bid, b.cover, b.title, b.content_id  " +
            "from bookshelf bs, user u, book b where bs.user_id = u.id and bs.book_id = b.id")
    List<Object[]> findPersonalAllBook();

    @Query(nativeQuery = true, value = "select u.id as uid,b.id as bid, b.cover, b.title, b.content_id  " +
            "from bookshelf bs, user u, book b where bs.user_id = u.id and bs.book_id = b.id and bs.user_id = ?1")
    List<Object[]> findPersonalAllBook(Integer userId);
}
